package com.manli.api.controller;

import java.util.Arrays;
import java.util.Map;

import com.manli.api.pojo.QueryParamsNoticeYip;
import com.manli.api.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.manli.api.base.annotation.Permissions;
import com.manli.api.pojo.QueryParams;
import com.manli.api.dto.NoticeTip;
import com.manli.api.service.NoticeTipService;

import javax.servlet.http.HttpServletRequest;


/**
 * 公告消息
 *
 * @author manli
 * @email 
 * @date 2020-07-25 20:04:58
 */
@Api(value="/noticetip", tags="公告消息")
@RestController
@RequestMapping("api/noticetip")
public class NoticeTipController {
    @Autowired
    private NoticeTipService noticeTipService;

    /**
     * 列表
     */
    @ApiOperation(value = "公告消息列表",notes = "")
    @PostMapping("/list")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result list(@RequestBody QueryParamsNoticeYip params){
        return noticeTipService.queryPage(params);
    }

    /**
     * 全部数据信息
     */
    @ApiOperation(value = "公告消息全部数据信息",notes = "")
    @PostMapping("/all")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result all(){
        return noticeTipService.queryAll();
    }

    /**
     * 单条信息
     */
    @ApiOperation(value = "公告消息单条信息",notes = "公告消息单条信息")
    @GetMapping("/info/{noticeTipId}")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result info(@PathVariable("noticeTipId") Integer noticeTipId){
        return noticeTipService.getById(noticeTipId);
    }

    /**
     * 保存
     */
    @ApiOperation(value = "公告消息保存",notes = "公告消息保存")
    @PostMapping("/save")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result save(@RequestBody NoticeTip noticeTip, HttpServletRequest request){
        return noticeTipService.save(noticeTip,request);
    }

    /**
     * 修改
     */
    @ApiOperation(value = "公告消息修改",notes = "公告消息修改")
    @PostMapping("/update")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result update(@RequestBody NoticeTip noticeTip){
        return noticeTipService.updateById(noticeTip);
    }


    /**
     * 删除多条数据
     */
    @ApiOperation(value = "公告消息删除",notes = "公告消息删除")
    @ApiImplicitParam(name = "noticeTipIds", value = "id数组,json字符串",dataType = "id数组,json字符串", required = true)
    @PostMapping("/deleteIds")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result deleteIds(@RequestBody Integer[] noticeTipIds){
        return noticeTipService.removeByIds(Arrays.asList(noticeTipIds));
    }

}
